

import java.io.File;
import java.sql.Connection;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;

public class ValidateListExcelFile
{
  
  public static final boolean validate(String hostName, String fileName,
      File xlsFileName, String apwDsnName, String loadId, String cmpnInfoId)
      throws Exception
  {
    boolean result = true;

    Workbook w = Workbook.getWorkbook(xlsFileName);

    //Connection conn = null;
    try
    {

      Sheet s = w.getSheet(0);

      Cell[] cells = s.getRow(1);
      String version = cells[0].getContents();
      System.out.println("Row 1 cell 0");
      System.out.println("Version " + version);

      if (!version.trim().equals("Version 1.0"))
      {
        System.out.println("INVALID_VERSION_ERROR");
        result = false;
      }

      /*
       * cells = s.getRow(5); String invalidRecords = cells[4].getContents(); //
       * System.out.println("Invalid Records" + invalidRecords);
       * 
       * if (invalidRecords == null || !invalidRecords.trim().equals("0"))
       * result = false; // System.out.println("HostName: ." + hostName + ".");
       * 
       * System.out.println("Class Code = " + Site.getSiteInfo().classCode);
       */
      
      String appworxUploadChain = "PlaceAppworxchainNameHere";
      System.out.println("submitting appworx chain: " + appworxUploadChain);
      
    } catch (Exception e) {
      System.out.println( "INVALID_FILE_ERROR");
      e.printStackTrace();
    } finally
    {
      w.close();
      
    }

    return result;
  }
  
  private static String getAppworxUploadChain(String cmpnInfoId)
  {
    return "CWE_HCA_CUST_LST_LD_HOLD";
  }
}